<template>
	<view>
		<view class="wrap">
			<!-- <view class="u-tabs-box">
				<u-tabs-swiper activeColor="#f29100" ref="tabs" :list="list" :current="current" @change="change" :is-scroll="false" swiperWidth="750"></u-tabs-swiper>
			</view> -->
			<view class="top">
			</view>
			<view class="moreArt" >
				<article-list-component :listData="artList"></article-list-component>
			</view>
			<!-- <swiper class="swiper-box" :current="swiperCurrent" @transition="transition" @animationfinish="animationfinish">
				<swiper-item class="swiper-item" v-for="(item) in list" :key="index">
					<scroll-view scroll-y style="height: 100%;width: 100%;" @scrolltolower="reachBottom">
						<view class="moreArt">
							  <u-card border="false" :title="item.title"  v-for="(item,index) in artList" :key="index" @click="clickAtr(item.id)">
									<view class="" slot="body">
										<view class="u-body-item u-flex u-border-bottom u-col-between u-p-t-0">
											<view class="u-body-item-title u-line-2">{{item.content}}</view>
										</view>
									</view>
									<view slot="foot">
										<div style="width: 100%;">
											<div style="width: 79%; float: left;">时间：{{$u.timeFormat(item.createTime, 'yyyy年mm月dd日')}}</div>
											<div  style="width: 20%; float: right;">{{item.typeName}}</div>
										</div>
									</view>
								</u-card>
						</view>
					</scroll-view>
				</swiper-item>
				
			</swiper> -->
		</view>
	</view>
</template>

<script>
// import { fork } from 'child_process';
import ArticleListComponent from '@/components/uni/article-list-component.vue';
export default {
	components: {
		    ArticleListComponent
		  },
	data() {
		return {
			// list: [
			// 	{
			// 		name: '政策解读'
			// 	},
			// 	{
			// 		name: '党史学习'
			// 	},
			// 	{
			// 		name: '特色党建'
			// 	},
			// ],
			artList : [],
			scrollTop: 0,
			current: 0,
			swiperCurrent: 0,
			dx: 0,
			loadStatus: [],
			from:{},
			pageNum:1,
			pageSize:10,
		};
	},
		onLoad: function (option) {
			this.swiperCurrent = option.type //上个页面传递的参数。
			this.current = this.swiperCurrent
			this.selectArtList();
			uni.$on('findIndexArtList', (obj) => {
				// 获取数据
				this.selectArtList();
			})
		},
		onUnload() {
			// 移除监听事件  
			uni.$off('findIndexArtList');
		},
	computed: {
	},
	methods: {
		selectArtList(){
			let url = "/api/artApi/list";
			this.$u.get(url, {
				"type": this.swiperCurrent,
				pageNum: this.pageNum,
				pageSize: this.pageSize,
				orderByColumn: 'createTime',
				isAsc: 'desc'
			}).then(result => {
				const data = result.rows;
				this.artList = data;
				console.log(this.artList,"arelist")
				if(this.pageNum>1 && data.length < this.pageSize){
					return this.loadStatus = 'nomore';
				}
				++ this.pageNum 
				this.loadStatus = 'loadmore';
			});
		},
		clickAtr(item){
				this.$u.route({
					url : 'pages/center/artShow',
					params:{
						id : item.id,
						title : item.title,
						content : item.content,
						createTime : item.createTime,},
						})
		},
		// tab栏切换
		change(index) {
			this.swiperCurrent = index;
			this.current = this.swiperCurrent;
			this.pageNum = 1
			this.selectArtList(this.swiperCurrent);
		},
		onPageScroll(e) {
		    this.scrollTop = e.scrollTop;
		},
		onReachBottom() {
		    this.loadStatus = 'loading';
		    // 获取数据
			this.selectArtList(this.swiperCurrent)
		},
		// 下拉刷新
		onPullDownRefresh() {
			// 获取数据
			this.selectArtList(this.swiperCurrent)
			// 关闭刷新
			uni.stopPullDownRefresh();
		},
		// typeNameFormat(option){
		// 	this.showList = [];
		// 	this.artList.forEach((item) => {
		// 	   	if(item.type == option){
		// 	   		this.showList.push(item);
		// 	   	}
		// 	})
		// },
		// transition({ detail: { dx } }) {
		// 	// this.$refs.tabs.getCurrent()
		// 	this.$refs.tabs.setDx(dx);
		// },
		// animationfinish({ detail: { current } }) {
		// 	this.$refs.tabs.setFinishCurrent(current);
		// 	this.swiperCurrent = current;
		// 	this.selectArtList(this.swiperCurrent );
		// 	this.current = current;
		// },
		reachBottom(){}
	}
};
</script>

<style>
/* #ifndef H5 */
page {
	height: 100%;
	background-color: #f2f2f2;
}
/* #endif */
</style>

<style lang="scss" scoped>
.top{
	margin-top: 10rpx;
	// background-color: red;
}
.order {
	width: 710rpx;
	background-color: #ffffff;
	margin: 20rpx auto;
	border-radius: 20rpx;
	box-sizing: border-box;
	padding: 20rpx;
	font-size: 28rpx;
	.top {
		display: flex;
		justify-content: space-between;
		.left {
			display: flex;
			align-items: center;
			.store {
				margin: 0 10rpx;
				font-size: 32rpx;
				font-weight: bold;
			}
		}
		.right {
			color: $u-type-warning-dark;
		}
	}
	.item {
		display: flex;
		margin: 20rpx 0 0;
		.left {
			margin-right: 20rpx;
			image {
				width: 200rpx;
				height: 200rpx;
				border-radius: 10rpx;
			}
		}
		.content {
			.title {
				font-size: 28rpx;
				line-height: 50rpx;
			}
			.type {
				margin: 10rpx 0;
				font-size: 24rpx;
				color: $u-tips-color;
			}
			.delivery-time {
				color: #e5d001;
				font-size: 24rpx;
			}
		}
		.right {
			margin-left: 10rpx;
			padding-top: 20rpx;
			text-align: right;
			.decimal {
				font-size: 24rpx;
				margin-top: 4rpx;
			}
			.number {
				color: $u-tips-color;
				font-size: 24rpx;
			}
		}
	}
	.total {
		margin-top: 20rpx;
		text-align: right;
		font-size: 24rpx;
		.total-price {
			font-size: 32rpx;
		}
	}
	.bottom {
		display: flex;
		margin-top: 40rpx;
		padding: 0 10rpx;
		justify-content: space-between;
		align-items: center;
		.btn {
			line-height: 52rpx;
			width: 160rpx;
			border-radius: 26rpx;
			border: 2rpx solid $u-border-color;
			font-size: 26rpx;
			text-align: center;
			color: $u-type-info-dark;
		}
		.evaluate {
			color: $u-type-warning-dark;
			border-color: $u-type-warning-dark;
		}
	}
}
.centre {
	text-align: center;
	margin: 200rpx auto;
	font-size: 32rpx;
	image {
		width: 164rpx;
		height: 164rpx;
		border-radius: 50%;
		margin-bottom: 20rpx;
	}
	.tips {
		font-size: 24rpx;
		color: #999999;
		margin-top: 20rpx;
	}
	.btn {
		margin: 80rpx auto;
		width: 200rpx;
		border-radius: 32rpx;
		line-height: 64rpx;
		color: #ffffff;
		font-size: 26rpx;
		background: linear-gradient(270deg, rgba(249, 116, 90, 1) 0%, rgba(255, 158, 1, 1) 100%);
	}
}
.wrap {
	display: flex;
	flex-direction: column;
	height: calc(100vh - var(--window-top));
	width: 100%;
}
.swiper-box {
	flex: 1;
}
.swiper-item {
	height: 100%;
}
</style>
